<template xmlns="">
  <div style="background-color: #F2F2F2;color: #606266;min-height: 100vh;">
    <blue-nav/>
    <el-row type="flex" justify="center">
      <el-row class="el-menu-demo"
              style="background-color: #3878F6;height: 61px;border-bottom-left-radius:0;border-bottom-right-radius:0 ">
        <el-col :span="3" class="my-text">
          统一资源管理系统
        </el-col>

      </el-row>
    </el-row>
    <el-row type="flex" justify="center">
      <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" style="margin: 20px 0"
               @select="handleSelect">
        <el-menu-item :index="v.permissionUrl" v-for="(v,i) in menu">{{ v.permissionName }}</el-menu-item>
      </el-menu>
    </el-row>
    <el-row type="flex" justify="center">
      <div style="width: 95vw">
        <router-view/>
      </div>
    </el-row>
  </div>
</template>

<script>

import service from "@/api/service";
import blueNav from "@/components/blueNav";
export default {
  name: 'layout',
  components: {blueNav},
  data() {
    return {
      activeIndex: '',
      path: ['/index/user', '/index/role', '/index/resources', '/index/mechanism', '/index/dic', '/index/client'],
      menu: []
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    handleSelect(key, keyPath) {
      this.$router.push({path: key})
    },
    toNav() {
      this.$router.push({path: '/home'})
    },
    init() {
      service.get('/small-service-account/au-permission/findTree',{
        scope:'account'
      }).then(res => {
        if (res.status === 200) {
          this.menu = res.data[0].children
          this.activeIndex = this.menu[0].permissionUrl;
        }
      })
    }
  }
}
</script>

<style scoped lang="less">
.img-nav {
  width: 100vw;
  height: 200px;
  position: absolute;
  top: 0;
}

.el-menu-demo {
  width: 95%;
  border-radius: 4px;
  //background-color: white;
}

.my-text {
  background-color: #2A61DC;
  border-top-left-radius: 4px;
  color: white;
  font-size: 18px;
  font-weight: 200;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
